<!DOCTYPE html>
<html lang="zh">

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
	<title>注册</title>
	<link rel="icon" href="favicon.ico" type="image/ico">
	<link href="/static/css/bootstrap.min.css" rel="stylesheet">
	<link href="/static/css/materialdesignicons.min.css" rel="stylesheet">
	<link href="/static/css/style.min.css" rel="stylesheet">
	<link rel="stylesheet" href="/static/css/style.css" />
	<script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script>
	<script type="text/javascript" src="/static/js/script.js"></script>
	<script src="/static/js/jquery-3.1.1.min.js"></script>
	<style>
		.lyear-wrapper {
			position: relative;
		}

		.lyear-login {
			display: flex !important;
			min-height: 100vh;
			align-items: center !important;
			justify-content: center !important;
		}

		.lyear-login:after {
			content: '';
			min-height: inherit;
			font-size: 0;
		}

		.login-center {
			background: #fff;
			min-width: 29.25rem;
			padding: 2.14286em 3.57143em;
			border-radius: 3px;
			margin: 2.85714em;
		}

		.login-header {
			margin-bottom: 1.5rem !important;
		}

		.login-center .has-feedback.feedback-left .form-control {
			padding-left: 38px;
			padding-right: 12px;
		}

		.login-center .has-feedback.feedback-left .form-control-feedback {
			left: 0;
			right: auto;
			width: 38px;
			height: 38px;
			line-height: 38px;
			z-index: 4;
			color: #dcdcdc;
		}

		.login-center .has-feedback.feedback-left.row .form-control-feedback {
			left: 15px;
		}
	</style>

	<script>
		$(document).ready(function(){
			$("#submit-btn").click(function(){
				var userName = $("#userName").val();
				if(userName==""){
					alert('用户名不能为空');
					return ;
				}
				var userIdCard = $("#userIdCard").val();
				if(userIdCard ==""){
					alert('身份证号不能为空');
					return ;
				}
				var userPhone = $("#userPhone").val();
				var userEmail = $("#userEmail").val();
				var userAddress = $("#userAddress").val();
				var userPassword = $("#userPassword").val();
				var CuserPassword = $("#CuserPassword").val();
				var userPayPassword = $("#userPayPassword").val();
				var CuserPayPassword = $("#CuserPayPassword").val();
				var data = $("#login-form").serialize();

				if(userPhone==""){
					alert('手机号码不能为空');
					return ;
				}
				if(userEmail==""){
					alert('邮箱不能为空');
					return ;
				}
				if(userAddress==""){
					alert('地址不能为空');
					return ;
				}
				if(userPassword==""){
					alert('登录密码不能为空');
					return ;
				}
				if(CuserPassword==""){
					alert('确认登录密码不能为空');
					return ;
				}
				if(userPayPassword==""){
					alert('支付密码不能为空');
					return ;
				}
				if(CuserPassword==""){
					alert('确认支付密码不能为空');
					return ;
				}
				if(userPassword!=CuserPassword){
					alert('两次密码输入不一致！');
					return ;
				}
				if(userPayPassword!=CuserPayPassword){
					alert('两次支付密码输入不一致！');
					return ;
				}
				$.ajax({
					url:'reg',
					type:'POST',
					data:data,
					dataType:'json',
					success:function(data){
						if(data.code == 200){
							alert('注册成功');
							window.location.href = 'toRegister';
						}else{
							alert(data.message);

						}
					},
					error:function(data){
						alert('网络错误!');
					}
				});
			});
		});

		$(document).ready(function () {
			let msg = '[[${msg}]]'
			if(msg==100){
				alert("不存在该账号!");
			}
			if(msg==200){
				alert("密码错误！")
			}
			if(msg==400){
				alert("注册成功!");
			}
			if(msg==500){
				alert("注册失败!")
			}
			if(msg==600){
				alert("实名信息不存在!")
			}
			if(msg==700){
				alert("密码或账户名不能为空!")
			}
			if(msg==800){
				alert("该用户已经注册了电子账户!")
			}
			if(msg==900){
				alert("电子账户名不可包含中文!")
			}
			if(msg==1000){
				alert("用户名和电话号码不匹配!")
			}
		})

		$(function () {
			$("#userphone").blur(function () {
				var userphone = $("#userphone").val()
				if (userphone !== "") {
					$.ajax({
						url: "getusername",
						type: "post",
						data: {
							userphone: userphone
						},
						dataType: "text",
						success: function (data) {
							if (data === "2") {
								alert("不存在的电话号")
							}
						},
					})
				}
			})
		})

		$(function (){
			$("#E_Account_Name").blur(function () {
				var E_Account_Name = $("#E_Account_Name").val()
				if (E_Account_Name !== "") {
					$.ajax({
						url: "getusername",
						type: "post",
						data: {
							E_Account_Name: E_Account_Name,
						},
						dataType: "text",
						success: function (data) {
							if (data === "0") {
								$("#tip3").html("该账户名可用".fontcolor("#049d1d"));
							} else {
								$("#tip3").html("该电子账户名已经注册,或包含中文".fontcolor("#d90404"))

							}
						},

					})
				}
			})
		})



		$(function (){
			$("#username").blur(function () {
				var username=$("#username").val()
				if (username !== "") {
					$.ajax({
						url: "getusername",
						type: "post",
						data: {
							username:username,
						},
						dataType: "text",
						success: function (data) {
							if(data==="1"){
								alert("不存在的用户名")
							}
						},

					})
				}
			})
		})





		$(function () {

			let msg1;
			let msg5;

			$("#Login_password,#reLogin_password").blur(function () {
				var Login_password = $("#Login_password").val();
				var reLogin_password = $("#reLogin_password").val();
				if (Login_password.length > 5 && Login_password.length < 17) {

					msg5 = "密码可用"
					$("#msg5").html(msg5.fontcolor("#049d1d"));
					if (Login_password.trim() === "" || reLogin_password.trim() === "" || reLogin_password !== Login_password) {
						msg1 = "两次输入登录密码不相同";
						$("#tip1").html(msg1.fontcolor("#D90404"));
					} else {
						$("#tip1").html("");

					}
				} else {
					msg5 = "请输入正确格式的密码"
					$("#msg5").html(msg5.fontcolor("#D90404"));
				}


			})
		})


		$(function () {

			let msg2;
			let msg3;

			$("#E_Account_Password,#reE_Account_Password").blur(function () {
				var E_Account_Password = $("#E_Account_Password").val();
				var reE_Account_Password = $("#reE_Account_Password").val();
				if(E_Account_Password.length===6){
					msg3="密码可用"
					$("#msg3").html(msg3.fontcolor("#049d1d"));
					if (E_Account_Password.trim() === "" || reE_Account_Password.trim() ==="" || reE_Account_Password !== E_Account_Password) {
						msg2= "两次输入支付密码不相同";

						$("#tip2").html(msg2.fontcolor("#D90404"));
					}else{
						$("#tip2").html("");

					}

				}else{
					msg3="请输入正确格式的密码"
					$("#msg3").html(msg3.fontcolor("#D90404"));
				}


			})

		})
		//校验登录密码
		function checklogpwd(){
			var check=false;
			var loginpwd=$("#Login_password").val();
			if(loginpwd!="" && loginpwd.length>5 && loginpwd.length<17){
				check=true;
			}else {
				check=false;
			}
			return check;
		}
		//校验用户名
		function checkusername(){
			var check=false;
			var username=$("#username").val();
			if(username!=""){
				check=true;
			}else {
				check=false;
			}
			return check;
		}
		//校验电话号
		function checkuserphone(){
			var check=false;
			var userphone=$("#userphone").val();
			if(userphone!="" && userphone.length==11){
				check=true;
			}else {
				check=false;
			}
			return check;
		}
		//校验电子账户名
		function checkeaccount(){
			var check=false;
			var eaccount=$("#E_Account_Name").val();
			if(eaccount!="" && !eaccount.test(/^[a-zA-Z0-9\u2E80-\u9FFF._-]{3,16}$/)){
				check=true;
			}else {
				check=false;
			}
			return check;
		}
		//校验re密码
		function checkrelogpwd(){
			var check=false;
			var reloginpwd=$("#reLogin_password").val();
			if(reloginpwd!="" && reloginpwd.length>5 && reloginpwd.length<17){
				check=true;
			}else {
				check=false;
			}
			return check;
		}
		//校验支付密码
		function checkpaypwd(){
			var check=false;
			var paypwd=$("#E_Account_Password").val();
			if(paypwd!="" && paypwd.length==6){
				check=true;
			}else {
				check=false;
			}
			return check;
		}



		//校验re支付密码
		function checkrepaypwd(){
			var check=false;
			var repaypwd=$("#reE_Account_Password").val();
			if(repaypwd!="" && repaypwd.length==6){
				check=true;
			}else {
				check=false;
			}
			return check;
		}


		function check(){
			var check=checkrelogpwd()&&checkeaccount()&&checklogpwd()
					&&checkusername()&&checkuserphone()&&checkrepaypwd()&&checkpaypwd();

			return check;
		}

		$(function (){
			$("#submit").click(function(){
				if(!check()){
					alert("请按提示要求输入正确数据格式后再提交")
				}
			})
		})

		// $(function disable(){
		// 	var check=checkpaypwd();
		// 	if(!check){
		// 		document.getElementByIdx("submit").disabled=true;
		// 	}
		// })



	</script>
</head>

<body>
<div class="row lyear-wrapper" style="background-image: url(/static/img/login-bg-3.jpg); background-size: cover;">
	<div class="lyear-login">
		<div class="login-center">
			<div class="login-header text-center">
				<a>新用户注册</a>
			</div>
			<form  id="login-form" method="post" onsubmit="return check()">

				<div class="form-group has-feedback feedback-left">
					<input type="text" placeholder="请输入您的姓名" class="form-control" id="userName" name="userName"/>
					<span class="mdi mdi-account form-control-feedback" aria-hidden="true"></span>
				</div>
				<div class="form-group has-feedback feedback-left">
					<input type="text" placeholder="请输入身份证号" class="form-control" id="userIdCard" name="userIdCard"/>
					<span class="mdi mdi-account form-control-feedback" aria-hidden="true"></span>
				</div>
				<div class="form-group has-feedback feedback-left">
					<input type="text" placeholder="请输入您的地址" class="form-control" id="userAddress" name="userAddress"/>
					<span class="mdi mdi-account form-control-feedback" aria-hidden="true"></span>
				</div>
				<div class="form-group has-feedback feedback-left">
					<input type="text" placeholder="请输入手机号(11位)" class="form-control" id="userPhone" name="userPhone"/>
					<span class="mdi mdi-account form-control-feedback" aria-hidden="true"></span>
				</div>

				<p class="help-block" name="tip3" id="tip3"></p>
				<div class="form-group has-feedback feedback-left">
					<input type="text" placeholder="请输电子邮箱" class="form-control" name="userEmail" id="userEmail"/>
					<span class="mdi mdi-account form-control-feedback" aria-hidden="true"></span>
				</div>

				<div class="form-group has-feedback feedback-left">
					<input type="password" placeholder="请输入登录密码(6~16位)" class="form-control" id="userPassword" name="userPassword"/>
					<span class="mdi mdi-account form-control-feedback" aria-hidden="true"></span>
				</div>
				<p class="help-block" name="msg5" id="msg5"></p>



				<div class="form-group has-feedback feedback-left">
					<input type="password" placeholder="请确认密码" class="form-control" name="CuserPassword" id="CuserPassword"/>
					<span class="mdi mdi-account form-control-feedback" aria-hidden="true"></span>
				</div>
				<p class="help-block" name="tip1" id="tip1"></p>


				<div class="form-group has-feedback feedback-left">
					<input type="password" placeholder="请输入支付密码" class="form-control" name="userPayPassword" id="userPayPassword"/>
					<span class="mdi mdi-account form-control-feedback" aria-hidden="true"></span>
				</div>
				<p class="help-block" name="msg3" id="msg3"></p>



				<div class="form-group has-feedback feedback-left">
					<input type="password" placeholder="请确认支付密码" class="form-control" name="CuserPayPassword" id="CuserPayPassword"/>
					<span class="mdi mdi-account form-control-feedback" aria-hidden="true"></span>
				</div>
				<p class="help-block" name="tip2" id="tip2"></p>


				<div class="form-group has-feedback feedback-left row">

					<div class="col-xs-5">

					</div>
				</div>
				<div class="form-group">
					<button class="btn btn-block btn-primary" type="button" id="submit-btn" >立即注册</button>
				</div>
				<div class="form-group">
					<a class="btn btn-block btn-primary" href="toLogin"  >去登陆</a>
				</div>
			</form>
			<hr>

		</div>
	</div>
</div>

<script type="text/javascript" src="/static/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/static/js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="/static/js/main.min.js"></script>

<!--图表插件-->
<script type="text/javascript" src="/static/js/Chart.js"></script>
<script type="text/javascript">
</script>
</body>

</html>
